package entity;

import com.github.javaparser.ast.type.TypeParameter;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.JavaConstructor;
import com.thoughtworks.qdox.model.JavaField;
import com.thoughtworks.qdox.model.JavaMethod;
import type.AccessModifierEnum;
import type.ClassTypeEnum;

import java.util.List;

/**
 * 实体：【类】/【接口】/【枚举】，枚举常量在 fields 中
 *
 * @author Tao Lu
 */
public class ClassEntity extends BaseEntity {
    private String name;    // 类的全限定名
    private ClassTypeEnum classTypeEnum;    // 类 or 接口 or 枚举 or 注解类：CLASS, INTERFACE, ENUM, ANNOTATION
    private JavaClass superClass;  // 继承的类
    private List<JavaClass> interfaces;    // 实现的接口
    private AccessModifierEnum accessModifierEnum;  // 访问修饰符：PUBLIC, PROTECTED, PRIVATE, DEFAULT
    private boolean isAbstract; // 是否是抽象类
    private boolean isStatic;   // 是否是静态类
    private boolean isFinal;    // 是否允许重写
    private boolean isStrictfp; // 精确浮点

    private List<JavaConstructor> constructors;   // 构造器列表
    private List<JavaField> fields;    // 成员变量
    private List<JavaMethod> methods;   // 成员方法
    private List<TypeParameter> typeParameters;  // 泛型参数声明
    private List<String> imports;   // 导入的包

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ClassTypeEnum getClassTypeEnum() {
        return classTypeEnum;
    }

    public void setClassTypeEnum(ClassTypeEnum classTypeEnum) {
        this.classTypeEnum = classTypeEnum;
    }

    public AccessModifierEnum getAccessModifierEnum() {
        return accessModifierEnum;
    }

    public void setAccessModifierEnum(AccessModifierEnum accessModifierEnum) {
        this.accessModifierEnum = accessModifierEnum;
    }

    public boolean isAbstract() {
        return isAbstract;
    }

    public void setAbstract(boolean anAbstract) {
        isAbstract = anAbstract;
    }

    public boolean isStatic() {
        return isStatic;
    }

    public void setStatic(boolean aStatic) {
        isStatic = aStatic;
    }

    public boolean isFinal() {
        return isFinal;
    }

    public void setFinal(boolean aFinal) {
        isFinal = aFinal;
    }

    public boolean isStrictfp() {
        return isStrictfp;
    }

    public void setStrictfp(boolean aStrictfp) {
        isStrictfp = aStrictfp;
    }

    public JavaClass getSuperClass() {
        return superClass;
    }

    public void setSuperClass(JavaClass superClass) {
        this.superClass = superClass;
    }

    public List<JavaClass> getInterfaces() {
        return interfaces;
    }

    public void setInterfaces(List<JavaClass> interfaces) {
        this.interfaces = interfaces;
    }

    public List<JavaConstructor> getConstructors() {
        return constructors;
    }

    public void setConstructors(List<JavaConstructor> constructors) {
        this.constructors = constructors;
    }

    public List<JavaField> getFields() {
        return fields;
    }

    public void setFields(List<JavaField> fields) {
        this.fields = fields;
    }

    public List<JavaMethod> getMethods() {
        return methods;
    }

    public void setMethods(List<JavaMethod> methods) {
        this.methods = methods;
    }

    public List<TypeParameter> getTypeParameters() {
        return typeParameters;
    }

    public void setTypeParameters(List<TypeParameter> typeParameters) {
        this.typeParameters = typeParameters;
    }

    public List<String> getImports() {
        return imports;
    }

    public void setImports(List<String> imports) {
        this.imports = imports;
    }

    @Override
    public String toString() {
        return "ClassEntity{\n\t" + super.toString() +
                "\n\t\"name\":\"" +
                name + '\"' +
                ",\n\t\"classTypeEnum\":" +
                classTypeEnum +
                ",\n\t\"superClass\":" +
                superClass +
                ",\n\t\"interfaces\":" +
                interfaces +
                ",\n\t\"accessModifierEnum\":" +
                accessModifierEnum +
                ",\n\t\"isAbstract\":" +
                isAbstract +
                ",\n\t\"isStatic\":" +
                isStatic +
                ",\n\t\"isFinal\":" +
                isFinal +
                ",\n\t\"isStrictfp\":" +
                isStrictfp +
                ",\n\t\"constructors\":" +
                constructors +
                ",\n\t\"fields\":" +
                fields +
                ",\n\t\"methods\":" +
                methods +
                ",\n\t\"typeParameters\":" +
                typeParameters +
                ",\n\t\"imports\":" +
                imports +
                "\n}";
    }
}

